#图片路径
imagePath=$PWD'/config/baseConfig/icon.png'
if [ ! -f "$imagePath" ]; then
    echo $imagePath"不存在！"
    exit 0
fi

echo $PWD

#输出保存路径
exportPath=./zn_backup
# 配置尺寸数组
imageSize=(36 48 72 96 114 192)


#制作完成的图标文件路径
orig_image_dir=./android/app/src/main/res/
backup_image_dir=./zn_backup/





# 输入各个尺寸icon
iPhoneIconWithSize() {
iPhoneSize=`expr $1 \* 1`

    if [ $1 = '36' ]; then
        Target=mipmap-ldpi
    else
        if [ $1 = '48' ]; then
            Target=mipmap-mdpi
        else
            if [ $1 = '72' ]; then
                Target=mipmap-hdpi
            else
                if [ $1 = '96' ]; then
                    Target=mipmap-xhdpi
                else
                    if [ $1 = '114' ]; then
                        Target=mipmap-xxhdpi
                    else
                        if [ $1 = '192' ]; then
                            Target=mipmap-xxxhdpi
                        fi
                    fi
                fi
            fi
        fi
    fi

    tmp_image_dir=./zn_backup/${Target}
    if [ -d $tmp_image_dir ]; then
        rm -rf $tmp_image_dir
        mkdir $tmp_image_dir
    else mkdir $tmp_image_dir; fi

    sips -Z $iPhoneSize $imagePath --out ${tmp_image_dir}/ic_launcher.png
}

echo Android icon完成


if [ -d $exportPath ]; then
    rm -rf $exportPath
    mkdir $exportPath
else mkdir $exportPath; fi



for iPhoneSize in  ${imageSize[*]}
do
  iPhoneIconWithSize $iPhoneSize
done








# #遍历图片文件夹,移动到android目录
for eachfile in $(ls $backup_image_dir); do
      echo eachfile【${eachfile}】
    for file in $(ls $backup_image_dir$eachfile); do
      echo file【${file}】

       if [ -f "$backup_image_dir$eachfile/$file" ]; then
       echo '------------将文件【'${backup_image_dir}${eachfile}/${file}  '】复制到[' +${orig_image_dir}${eachfile}/${file}']------------'
       cp ${backup_image_dir}${eachfile}/${file} ${orig_image_dir}${eachfile}/${file}
    else
        echo '移动到android icon出现错误'
    fi
     
done

done




